package com.apply.entity;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;

/**
 * @author tianp
 */
@Entity
@Table(name = "sys_user")
@ApiModel(value = "SysUser", description = "用户信息对象")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
public class SysUser implements Serializable {

    @Id
    @Column(name = "u_id")
    @GeneratedValue
    @ApiModelProperty(value = "id", dataType = "long")
    private Long id;
    @Column(name = "u_username")
    @ApiModelProperty(value = "账号/邮箱", dataType = "string")
    private String username;
    @ApiModelProperty(value = "密码", dataType = "string")
    @Column(name = "u_password")
    private String password;
    @ApiModelProperty(value = "真实姓名", dataType = "string")
    @Column(name = "real_name")
    private String realname;
    @ApiModelProperty(value = "身份证号码", dataType = "string")
    @Column(name = "idcard")
    private String idcard;
    @ApiModelProperty(value = "性别", dataType = "string")
    @Column(name = "sex")
    private String sex;
    @ApiModelProperty(value = "手机号码", dataType = "string")
    @Column(name = "phone_num")
    private String phoneNum;
    /**
     * 头像路径
     */
    @ApiModelProperty(value = "头像路径", dataType = "string")
    private String photoPath;

    @OneToMany(mappedBy = "sysUser", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private Set<ApplyInfo> applyInfos;
    @CreatedDate
    private Date createTime;
    @LastModifiedDate
    private Date modifiedTime;
    /**
     * 1.普通用户，2管理员  暂时写死
     */
    private Integer roleId;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getRealname() {
        return realname;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }

    public String getIdcard() {
        return idcard;
    }

    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Set<ApplyInfo> getApplyInfos() {
        return applyInfos;
    }

    public void setApplyInfos(Set<ApplyInfo> applyInfos) {
        this.applyInfos = applyInfos;
    }

    public String getPhoneNum() {
        return phoneNum;
    }

    public void setPhoneNum(String phoneNum) {
        this.phoneNum = phoneNum;
    }

    public String getPhotoPath() {
        return photoPath;
    }

    public void setPhotoPath(String photoPath) {
        this.photoPath = photoPath;
    }

    public Integer getRoleId() {
        return roleId;
    }

    public void setRoleId(Integer roleId) {
        this.roleId = roleId;
    }
}
